#ifndef LOGGER_H
#define LOGGER_H

#include <stdio.h>
#include <stdlib.h>

#define DEFAULT_LOGGER_SEVERITY() 1
#ifndef LOGGER_SEVERITY
    #define LOGGER_SEVERITY DEFAULT_LOGGER_SEVERITY()
#endif  // LOGGER_SEVERITY

// if you want change compile time severity you should pass macro definition to make. E.g.:
// If you want see debug logs:
// make CFLAGS=-DLOGGER_SEVERITY=0
// If you want see only error logs:
// make CFLAGS=-DLOGGER_SEVERITY=3
// If you want not see any logs except of VIP:
// make CFLAGS=-DLOGGER_SEVERITY=4

#if LOGGER_SEVERITY==0
    #define LOG_DEBUG(format, ...)\
        printf("%s, %s:%d: DBG: " format "\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)
    #define TRACE() printf("%s, %s:%d:\n", __FILE__, __func__, __LINE__)
#else
    #define LOG_DEBUG(...)
    #define TRACE()
#endif

#if LOGGER_SEVERITY<=1
    #define LOG_INFO(format, ...)\
        printf("%s, %s:%d: INF: " format "\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)
#else
    #define LOG_INFO(...)
#endif

#if LOGGER_SEVERITY<=2
    #define LOG_WARNING(format, ...)\
        printf("%s, %s:%d: WRN: " format "\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)
#else
    #define LOG_WARNING(...)
#endif

#if LOGGER_SEVERITY<=3
    #define LOG_ERROR(format, ...)\
        printf("%s, %s:%d: ERR: " format "\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)
#else
    #define LOG_ERROR(...)
#endif

#define LOG_VIP(format, ...)\
    printf("%s, %s:%d: VIP: " format "\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)

// TODO: correct warnings for 1-argument calls:
// LOG_INFO("log");
// src/main.c:13:18: warning: ISO C99 requires at least one argument for the "..." in a variadic macro


#endif // LOGGER_H
